<?php

class FGridColumn
{
    
    private $text;
    
    private $size;
    
    private $align;
    
    private $hidden;
    
    private $sortable;
    
    private $hideable;
    
    const ALIGN_LEFT = 'left';
    const ALIGN_CENTER = 'center';
    const ALIGN_RIGHT = 'right';
    
    public function __construct($text = '', $size = 1, $align = 'left', $hidden = false, $sortable = true, $hideable = true)
    {
        $this->text = $text;
        $this->size = $size;
        $this->align = $align;
        $this->hidden = $hidden;
        $this->sortable = $sortable;
        $this->hideable = $hideable;
    }
    
    public function generate()
    {
        $visible = $this->hidden ? 'false' : 'true';
        $hidden = $this->hidden ? 'true' : 'false';
        $sortable = $this->sortable ? 'true' : 'false';
        $hideable = $this->hideable ? 'true' : 'false';        
        $size = abs($this->size) * 8;
        if ( $size <= 50 )
        {
            $size = 80;
        }
        elseif ( $size > 400 )
        {
            $size = 400;
        }
        
        return "{
                    text: '{$this->text}',
                    width: '$size',
                    align: '{$this->align}',
                    visible: $visible,
                    sortable: $sortable,
                    hideable: $hideable,
                    hidden: $hidden,
                }";
    }
    
    public function getText() {
        return $this->text;
    }

    public function setText($text) {
        $this->text = $text;
    }

    public function getSize() {
        return $this->size;
    }

    public function setSize($size) {
        $this->size = $size;
    }

    public function getHidden() {
        return $this->hidden;
    }

    public function setHidden($hidden) {
        $this->hidden = $hidden;
    }

    public function getNavigation() {
        return $this->navigation;
    }

    public function setNavigation($navigation) {
        $this->navigation = $navigation;
    }
    public function getAlign() {
        return $this->align;
    }

    public function setAlign($align) {
        $this->align = $align;
    }

    public function getSortable() {
        return $this->sortable;
    }

    public function setSortable($sortable) {
        $this->sortable = $sortable;
    }

    public function getHideable() {
        return $this->hideable;
    }

    public function setHideable($hideable) {
        $this->hideable = $hideable;
    }

}

?>
